package com.qingzhuge.log.event;

import com.qingzhuge.log.entity.SysLog;
import com.qingzhuge.log.service.ISysLogService;
import lombok.AllArgsConstructor;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;

/**
 * @author : zero.xiao
 * @description :
 * @date :2019-08-12 14:47
 * @modified : 异步监听日志事件
 */
@AllArgsConstructor
public class SysLogListener {
    private ISysLogService sysLogService;
    @Async
    @Order
    @EventListener(SysLogEvent.class)
    public void saveSysLog(SysLogEvent event) {
        SysLog sysLog = (SysLog) event.getSource();
        sysLogService.save(sysLog);
    }
}
